package com.qf.utils;

import org.apache.curator.RetryPolicy;
import org.apache.curator.framework.CuratorFramework;
import org.apache.curator.framework.CuratorFrameworkFactory;
import org.apache.curator.retry.ExponentialBackoffRetry;

/**
 * author:z
 * time:2021/12/23 17:09
 * description:创建客户端
 */
public class ZKUtils {

    public static CuratorFramework getClient(){
        RetryPolicy retryPolicy=new ExponentialBackoffRetry(1000,3);

        CuratorFramework curatorFramework = CuratorFrameworkFactory.newClient("192.168.85.128:2181", retryPolicy);

        curatorFramework.start();

        //第二种方式
        //CuratorFramework curatorFramework1 = CuratorFrameworkFactory.builder().connectString("192.168.85.128:2181").retryPolicy(retryPolicy).build();


        return  curatorFramework;
    }
}
